{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# DAY1（读取数据）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 如何导入csv数据：`pandas.read_csv`\n",
    "\n",
    "> CSV（逗号分隔值）是一种纯文本文件格式，用于存储表格数据（例如电子表格或数据库）。\n",
    "> 它本质上存储的表格数据包括数字和纯文本。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取路径\n",
    "import os\n",
    "path = os.getcwd()\n",
    "csv_name = \"demo.csv\"\n",
    "csv_path = os.path.join(path, f\"data\\{csv_name}\")\n",
    "# print(csv_path)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "csv_url = 'https://raw.githubusercontent.com/datoujinggzj/DataScienceCrashCourse/master/data/demo.csv'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>New Cases</th>\n",
       "      <th>Total Cases</th>\n",
       "      <th>Recovered</th>\n",
       "      <th>Deaths</th>\n",
       "      <th>Active Cases</th>\n",
       "      <th>Year</th>\n",
       "      <th>Month</th>\n",
       "      <th>Day</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>06/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>07/03/2020</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>08/03/2020</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>09/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>2020</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2020</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>816</th>\n",
       "      <td>31/05/2022</td>\n",
       "      <td>99</td>\n",
       "      <td>94742</td>\n",
       "      <td>92215</td>\n",
       "      <td>721</td>\n",
       "      <td>1410</td>\n",
       "      <td>2022</td>\n",
       "      <td>5</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>817</th>\n",
       "      <td>01/06/2022</td>\n",
       "      <td>115</td>\n",
       "      <td>94857</td>\n",
       "      <td>92310</td>\n",
       "      <td>721</td>\n",
       "      <td>1430</td>\n",
       "      <td>2022</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>818</th>\n",
       "      <td>02/06/2022</td>\n",
       "      <td>93</td>\n",
       "      <td>94950</td>\n",
       "      <td>92408</td>\n",
       "      <td>722</td>\n",
       "      <td>1424</td>\n",
       "      <td>2022</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>819</th>\n",
       "      <td>03/06/2022</td>\n",
       "      <td>118</td>\n",
       "      <td>95068</td>\n",
       "      <td>92512</td>\n",
       "      <td>722</td>\n",
       "      <td>1438</td>\n",
       "      <td>2022</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>820</th>\n",
       "      <td>04/06/2022</td>\n",
       "      <td>76</td>\n",
       "      <td>95144</td>\n",
       "      <td>92603</td>\n",
       "      <td>722</td>\n",
       "      <td>1423</td>\n",
       "      <td>2022</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>821 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           Date  New Cases  Total Cases  Recovered  Deaths  Active Cases  \\\n",
       "0    06/03/2020          1            1          0       0             1   \n",
       "1    07/03/2020          2            3          0       0             3   \n",
       "2    08/03/2020          0            3          0       0             3   \n",
       "3    09/03/2020          1            4          0       0             4   \n",
       "4    10/03/2020          1            5          0       0             5   \n",
       "..          ...        ...          ...        ...     ...           ...   \n",
       "816  31/05/2022         99        94742      92215     721          1410   \n",
       "817  01/06/2022        115        94857      92310     721          1430   \n",
       "818  02/06/2022         93        94950      92408     722          1424   \n",
       "819  03/06/2022        118        95068      92512     722          1438   \n",
       "820  04/06/2022         76        95144      92603     722          1423   \n",
       "\n",
       "     Year  Month  Day  \n",
       "0    2020      6    3  \n",
       "1    2020      7    3  \n",
       "2    2020      8    3  \n",
       "3    2020      9    3  \n",
       "4    2020     10    3  \n",
       "..    ...    ...  ...  \n",
       "816  2022      5   31  \n",
       "817  2022      1    6  \n",
       "818  2022      2    6  \n",
       "819  2022      3    6  \n",
       "820  2022      4    6  \n",
       "\n",
       "[821 rows x 9 columns]"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv(csv_url)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.1 读取原始数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>New Cases</th>\n",
       "      <th>Total Cases</th>\n",
       "      <th>Recovered</th>\n",
       "      <th>Deaths</th>\n",
       "      <th>Active Cases</th>\n",
       "      <th>Year</th>\n",
       "      <th>Month</th>\n",
       "      <th>Day</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>06/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>07/03/2020</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>08/03/2020</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>09/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>2020</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2020</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>816</th>\n",
       "      <td>31/05/2022</td>\n",
       "      <td>99</td>\n",
       "      <td>94742</td>\n",
       "      <td>92215</td>\n",
       "      <td>721</td>\n",
       "      <td>1410</td>\n",
       "      <td>2022</td>\n",
       "      <td>5</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>817</th>\n",
       "      <td>01/06/2022</td>\n",
       "      <td>115</td>\n",
       "      <td>94857</td>\n",
       "      <td>92310</td>\n",
       "      <td>721</td>\n",
       "      <td>1430</td>\n",
       "      <td>2022</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>818</th>\n",
       "      <td>02/06/2022</td>\n",
       "      <td>93</td>\n",
       "      <td>94950</td>\n",
       "      <td>92408</td>\n",
       "      <td>722</td>\n",
       "      <td>1424</td>\n",
       "      <td>2022</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>819</th>\n",
       "      <td>03/06/2022</td>\n",
       "      <td>118</td>\n",
       "      <td>95068</td>\n",
       "      <td>92512</td>\n",
       "      <td>722</td>\n",
       "      <td>1438</td>\n",
       "      <td>2022</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>820</th>\n",
       "      <td>04/06/2022</td>\n",
       "      <td>76</td>\n",
       "      <td>95144</td>\n",
       "      <td>92603</td>\n",
       "      <td>722</td>\n",
       "      <td>1423</td>\n",
       "      <td>2022</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>821 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "           Date  New Cases  Total Cases  Recovered  Deaths  Active Cases  \\\n",
       "0    06/03/2020          1            1          0       0             1   \n",
       "1    07/03/2020          2            3          0       0             3   \n",
       "2    08/03/2020          0            3          0       0             3   \n",
       "3    09/03/2020          1            4          0       0             4   \n",
       "4    10/03/2020          1            5          0       0             5   \n",
       "..          ...        ...          ...        ...     ...           ...   \n",
       "816  31/05/2022         99        94742      92215     721          1410   \n",
       "817  01/06/2022        115        94857      92310     721          1430   \n",
       "818  02/06/2022         93        94950      92408     722          1424   \n",
       "819  03/06/2022        118        95068      92512     722          1438   \n",
       "820  04/06/2022         76        95144      92603     722          1423   \n",
       "\n",
       "     Year  Month  Day  \n",
       "0    2020      6    3  \n",
       "1    2020      7    3  \n",
       "2    2020      8    3  \n",
       "3    2020      9    3  \n",
       "4    2020     10    3  \n",
       "..    ...    ...  ...  \n",
       "816  2022      5   31  \n",
       "817  2022      1    6  \n",
       "818  2022      2    6  \n",
       "819  2022      3    6  \n",
       "820  2022      4    6  \n",
       "\n",
       "[821 rows x 9 columns]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv(csv_path)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.2 即默认第n+1行为列名：`header = n`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>06/03/2020</th>\n",
       "      <th>1</th>\n",
       "      <th>1.1</th>\n",
       "      <th>0</th>\n",
       "      <th>0.1</th>\n",
       "      <th>1.2</th>\n",
       "      <th>2020</th>\n",
       "      <th>6</th>\n",
       "      <th>3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>07/03/2020</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>08/03/2020</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>09/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>2020</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2020</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>11/03/2020</td>\n",
       "      <td>2</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>2020</td>\n",
       "      <td>11</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>815</th>\n",
       "      <td>31/05/2022</td>\n",
       "      <td>99</td>\n",
       "      <td>94742</td>\n",
       "      <td>92215</td>\n",
       "      <td>721</td>\n",
       "      <td>1410</td>\n",
       "      <td>2022</td>\n",
       "      <td>5</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>816</th>\n",
       "      <td>01/06/2022</td>\n",
       "      <td>115</td>\n",
       "      <td>94857</td>\n",
       "      <td>92310</td>\n",
       "      <td>721</td>\n",
       "      <td>1430</td>\n",
       "      <td>2022</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>817</th>\n",
       "      <td>02/06/2022</td>\n",
       "      <td>93</td>\n",
       "      <td>94950</td>\n",
       "      <td>92408</td>\n",
       "      <td>722</td>\n",
       "      <td>1424</td>\n",
       "      <td>2022</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>818</th>\n",
       "      <td>03/06/2022</td>\n",
       "      <td>118</td>\n",
       "      <td>95068</td>\n",
       "      <td>92512</td>\n",
       "      <td>722</td>\n",
       "      <td>1438</td>\n",
       "      <td>2022</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>819</th>\n",
       "      <td>04/06/2022</td>\n",
       "      <td>76</td>\n",
       "      <td>95144</td>\n",
       "      <td>92603</td>\n",
       "      <td>722</td>\n",
       "      <td>1423</td>\n",
       "      <td>2022</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>820 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     06/03/2020    1    1.1      0  0.1   1.2  2020   6   3\n",
       "0    07/03/2020    2      3      0    0     3  2020   7   3\n",
       "1    08/03/2020    0      3      0    0     3  2020   8   3\n",
       "2    09/03/2020    1      4      0    0     4  2020   9   3\n",
       "3    10/03/2020    1      5      0    0     5  2020  10   3\n",
       "4    11/03/2020    2      7      0    0     7  2020  11   3\n",
       "..          ...  ...    ...    ...  ...   ...   ...  ..  ..\n",
       "815  31/05/2022   99  94742  92215  721  1410  2022   5  31\n",
       "816  01/06/2022  115  94857  92310  721  1430  2022   1   6\n",
       "817  02/06/2022   93  94950  92408  722  1424  2022   2   6\n",
       "818  03/06/2022  118  95068  92512  722  1438  2022   3   6\n",
       "819  04/06/2022   76  95144  92603  722  1423  2022   4   6\n",
       "\n",
       "[820 rows x 9 columns]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv(csv_path,header = 1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.3 改变列名（或为没有列名的数据赋予列名）：`names = [\"列名1\",\"列名2\",\"列名3\"...\"列名n\"]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>日期</th>\n",
       "      <th>新增</th>\n",
       "      <th>累积</th>\n",
       "      <th>恢复</th>\n",
       "      <th>死亡</th>\n",
       "      <th>现有病例</th>\n",
       "      <th>年</th>\n",
       "      <th>月</th>\n",
       "      <th>日</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>06/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>07/03/2020</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>08/03/2020</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>09/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>2020</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>10/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2020</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>816</th>\n",
       "      <td>31/05/2022</td>\n",
       "      <td>99</td>\n",
       "      <td>94742</td>\n",
       "      <td>92215</td>\n",
       "      <td>721</td>\n",
       "      <td>1410</td>\n",
       "      <td>2022</td>\n",
       "      <td>5</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>817</th>\n",
       "      <td>01/06/2022</td>\n",
       "      <td>115</td>\n",
       "      <td>94857</td>\n",
       "      <td>92310</td>\n",
       "      <td>721</td>\n",
       "      <td>1430</td>\n",
       "      <td>2022</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>818</th>\n",
       "      <td>02/06/2022</td>\n",
       "      <td>93</td>\n",
       "      <td>94950</td>\n",
       "      <td>92408</td>\n",
       "      <td>722</td>\n",
       "      <td>1424</td>\n",
       "      <td>2022</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>819</th>\n",
       "      <td>03/06/2022</td>\n",
       "      <td>118</td>\n",
       "      <td>95068</td>\n",
       "      <td>92512</td>\n",
       "      <td>722</td>\n",
       "      <td>1438</td>\n",
       "      <td>2022</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>820</th>\n",
       "      <td>04/06/2022</td>\n",
       "      <td>76</td>\n",
       "      <td>95144</td>\n",
       "      <td>92603</td>\n",
       "      <td>722</td>\n",
       "      <td>1423</td>\n",
       "      <td>2022</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>821 rows × 9 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             日期   新增     累积     恢复   死亡  现有病例     年   月   日\n",
       "0    06/03/2020    1      1      0    0     1  2020   6   3\n",
       "1    07/03/2020    2      3      0    0     3  2020   7   3\n",
       "2    08/03/2020    0      3      0    0     3  2020   8   3\n",
       "3    09/03/2020    1      4      0    0     4  2020   9   3\n",
       "4    10/03/2020    1      5      0    0     5  2020  10   3\n",
       "..          ...  ...    ...    ...  ...   ...   ...  ..  ..\n",
       "816  31/05/2022   99  94742  92215  721  1410  2022   5  31\n",
       "817  01/06/2022  115  94857  92310  721  1430  2022   1   6\n",
       "818  02/06/2022   93  94950  92408  722  1424  2022   2   6\n",
       "819  03/06/2022  118  95068  92512  722  1438  2022   3   6\n",
       "820  04/06/2022   76  95144  92603  722  1423  2022   4   6\n",
       "\n",
       "[821 rows x 9 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv(csv_path,header = 0,names = ['日期','新增','累积','恢复','死亡','现有病例','年','月','日'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.4 添加第n+1列为索引：`index_col=n`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>新增</th>\n",
       "      <th>累积</th>\n",
       "      <th>恢复</th>\n",
       "      <th>死亡</th>\n",
       "      <th>现有病例</th>\n",
       "      <th>年</th>\n",
       "      <th>月</th>\n",
       "      <th>日</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>日期</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>06/03/2020</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>07/03/2020</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>08/03/2020</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>09/03/2020</th>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>2020</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10/03/2020</th>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2020</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31/05/2022</th>\n",
       "      <td>99</td>\n",
       "      <td>94742</td>\n",
       "      <td>92215</td>\n",
       "      <td>721</td>\n",
       "      <td>1410</td>\n",
       "      <td>2022</td>\n",
       "      <td>5</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>01/06/2022</th>\n",
       "      <td>115</td>\n",
       "      <td>94857</td>\n",
       "      <td>92310</td>\n",
       "      <td>721</td>\n",
       "      <td>1430</td>\n",
       "      <td>2022</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>02/06/2022</th>\n",
       "      <td>93</td>\n",
       "      <td>94950</td>\n",
       "      <td>92408</td>\n",
       "      <td>722</td>\n",
       "      <td>1424</td>\n",
       "      <td>2022</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>03/06/2022</th>\n",
       "      <td>118</td>\n",
       "      <td>95068</td>\n",
       "      <td>92512</td>\n",
       "      <td>722</td>\n",
       "      <td>1438</td>\n",
       "      <td>2022</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>04/06/2022</th>\n",
       "      <td>76</td>\n",
       "      <td>95144</td>\n",
       "      <td>92603</td>\n",
       "      <td>722</td>\n",
       "      <td>1423</td>\n",
       "      <td>2022</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>821 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             新增     累积     恢复   死亡  现有病例     年   月   日\n",
       "日期                                                    \n",
       "06/03/2020    1      1      0    0     1  2020   6   3\n",
       "07/03/2020    2      3      0    0     3  2020   7   3\n",
       "08/03/2020    0      3      0    0     3  2020   8   3\n",
       "09/03/2020    1      4      0    0     4  2020   9   3\n",
       "10/03/2020    1      5      0    0     5  2020  10   3\n",
       "...         ...    ...    ...  ...   ...   ...  ..  ..\n",
       "31/05/2022   99  94742  92215  721  1410  2022   5  31\n",
       "01/06/2022  115  94857  92310  721  1430  2022   1   6\n",
       "02/06/2022   93  94950  92408  722  1424  2022   2   6\n",
       "03/06/2022  118  95068  92512  722  1438  2022   3   6\n",
       "04/06/2022   76  95144  92603  722  1423  2022   4   6\n",
       "\n",
       "[821 rows x 8 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv(csv_path,header = 0,names = ['日期','新增','累积','恢复','死亡','现有病例','年','月','日'], index_col=0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.5 取其中某些列：`usecols = [\"列名1\",\"列名2\",\"列名3\"...\"列名m\"]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>新增</th>\n",
       "      <th>累积</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>日期</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>06/03/2020</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>07/03/2020</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>08/03/2020</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>09/03/2020</th>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10/03/2020</th>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31/05/2022</th>\n",
       "      <td>99</td>\n",
       "      <td>94742</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>01/06/2022</th>\n",
       "      <td>115</td>\n",
       "      <td>94857</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>02/06/2022</th>\n",
       "      <td>93</td>\n",
       "      <td>94950</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>03/06/2022</th>\n",
       "      <td>118</td>\n",
       "      <td>95068</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>04/06/2022</th>\n",
       "      <td>76</td>\n",
       "      <td>95144</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>821 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             新增     累积\n",
       "日期                    \n",
       "06/03/2020    1      1\n",
       "07/03/2020    2      3\n",
       "08/03/2020    0      3\n",
       "09/03/2020    1      4\n",
       "10/03/2020    1      5\n",
       "...         ...    ...\n",
       "31/05/2022   99  94742\n",
       "01/06/2022  115  94857\n",
       "02/06/2022   93  94950\n",
       "03/06/2022  118  95068\n",
       "04/06/2022   76  95144\n",
       "\n",
       "[821 rows x 2 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv(csv_path,\n",
    "            header = 0,\n",
    "            names = ['日期','新增','累积','恢复','死亡','现有病例','年','月','日'], \n",
    "            index_col=0, \n",
    "            usecols = ['日期','新增','累积'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.6 取前n行：`nrows = n`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>新增</th>\n",
       "      <th>累积</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>日期</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>06/03/2020</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>07/03/2020</th>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>08/03/2020</th>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>09/03/2020</th>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10/03/2020</th>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>09/06/2020</th>\n",
       "      <td>2</td>\n",
       "      <td>632</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10/06/2020</th>\n",
       "      <td>3</td>\n",
       "      <td>635</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11/06/2020</th>\n",
       "      <td>5</td>\n",
       "      <td>640</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12/06/2020</th>\n",
       "      <td>5</td>\n",
       "      <td>645</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13/06/2020</th>\n",
       "      <td>1</td>\n",
       "      <td>646</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>100 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            新增   累积\n",
       "日期                 \n",
       "06/03/2020   1    1\n",
       "07/03/2020   2    3\n",
       "08/03/2020   0    3\n",
       "09/03/2020   1    4\n",
       "10/03/2020   1    5\n",
       "...         ..  ...\n",
       "09/06/2020   2  632\n",
       "10/06/2020   3  635\n",
       "11/06/2020   5  640\n",
       "12/06/2020   5  645\n",
       "13/06/2020   1  646\n",
       "\n",
       "[100 rows x 2 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv(csv_path,\n",
    "            header = 0,\n",
    "            names = ['日期','新增','累积','恢复','死亡','现有病例','年','月','日'], \n",
    "            index_col=0, \n",
    "            usecols = ['日期','新增','累积'],\n",
    "            nrows = 100)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1.7 时间转换"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>年_月_日</th>\n",
       "      <th>日期</th>\n",
       "      <th>新增</th>\n",
       "      <th>累积</th>\n",
       "      <th>恢复</th>\n",
       "      <th>死亡</th>\n",
       "      <th>现有病例</th>\n",
       "      <th>年</th>\n",
       "      <th>月</th>\n",
       "      <th>日</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2020-06-03</td>\n",
       "      <td>06/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>2020</td>\n",
       "      <td>6</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2020-07-03</td>\n",
       "      <td>07/03/2020</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2020-08-03</td>\n",
       "      <td>08/03/2020</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2020</td>\n",
       "      <td>8</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2020-09-03</td>\n",
       "      <td>09/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>2020</td>\n",
       "      <td>9</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2020-10-03</td>\n",
       "      <td>10/03/2020</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5</td>\n",
       "      <td>2020</td>\n",
       "      <td>10</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>816</th>\n",
       "      <td>2022-05-31</td>\n",
       "      <td>31/05/2022</td>\n",
       "      <td>99</td>\n",
       "      <td>94742</td>\n",
       "      <td>92215</td>\n",
       "      <td>721</td>\n",
       "      <td>1410</td>\n",
       "      <td>2022</td>\n",
       "      <td>5</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>817</th>\n",
       "      <td>2022-01-06</td>\n",
       "      <td>01/06/2022</td>\n",
       "      <td>115</td>\n",
       "      <td>94857</td>\n",
       "      <td>92310</td>\n",
       "      <td>721</td>\n",
       "      <td>1430</td>\n",
       "      <td>2022</td>\n",
       "      <td>1</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>818</th>\n",
       "      <td>2022-02-06</td>\n",
       "      <td>02/06/2022</td>\n",
       "      <td>93</td>\n",
       "      <td>94950</td>\n",
       "      <td>92408</td>\n",
       "      <td>722</td>\n",
       "      <td>1424</td>\n",
       "      <td>2022</td>\n",
       "      <td>2</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>819</th>\n",
       "      <td>2022-03-06</td>\n",
       "      <td>03/06/2022</td>\n",
       "      <td>118</td>\n",
       "      <td>95068</td>\n",
       "      <td>92512</td>\n",
       "      <td>722</td>\n",
       "      <td>1438</td>\n",
       "      <td>2022</td>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>820</th>\n",
       "      <td>2022-04-06</td>\n",
       "      <td>04/06/2022</td>\n",
       "      <td>76</td>\n",
       "      <td>95144</td>\n",
       "      <td>92603</td>\n",
       "      <td>722</td>\n",
       "      <td>1423</td>\n",
       "      <td>2022</td>\n",
       "      <td>4</td>\n",
       "      <td>6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>821 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         年_月_日          日期   新增     累积     恢复   死亡  现有病例     年   月   日\n",
       "0   2020-06-03  06/03/2020    1      1      0    0     1  2020   6   3\n",
       "1   2020-07-03  07/03/2020    2      3      0    0     3  2020   7   3\n",
       "2   2020-08-03  08/03/2020    0      3      0    0     3  2020   8   3\n",
       "3   2020-09-03  09/03/2020    1      4      0    0     4  2020   9   3\n",
       "4   2020-10-03  10/03/2020    1      5      0    0     5  2020  10   3\n",
       "..         ...         ...  ...    ...    ...  ...   ...   ...  ..  ..\n",
       "816 2022-05-31  31/05/2022   99  94742  92215  721  1410  2022   5  31\n",
       "817 2022-01-06  01/06/2022  115  94857  92310  721  1430  2022   1   6\n",
       "818 2022-02-06  02/06/2022   93  94950  92408  722  1424  2022   2   6\n",
       "819 2022-03-06  03/06/2022  118  95068  92512  722  1438  2022   3   6\n",
       "820 2022-04-06  04/06/2022   76  95144  92603  722  1423  2022   4   6\n",
       "\n",
       "[821 rows x 10 columns]"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv(csv_path,\n",
    "            header = 0,\n",
    "            names = ['日期','新增','累积','恢复','死亡','现有病例','年','月','日'], \n",
    "            parse_dates = [['年','月','日']],\n",
    "            infer_datetime_format=True, # 可显著减少read_csv命令日期解析时间\n",
    "            keep_date_col=True)         # 保存之前的日期格式"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 读取json\n",
    "\n",
    "JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。它基于ECMAScript的一个子集。 JSON采用完全独立于语言的文本格式，但是也使用了类似于C语言家族的习惯(包括C、C++、Java、JavaScript、Perl、Python等)。这些特性使JSON成为理想的数据交换语言。易于人阅读和编写，同时也易于机器解析和生成(一般用于提升网络传输速率)。\n",
    "\n",
    "JSON结构看起来和Python中的字典非常类似。需要注意的是，JSON格式通常是由key: 结对组成,其中key是字符串形式,value是字符串、数字、布尔值、数组、对象或null。\n",
    "\n",
    "JSON在python中分别由list和dict组成。\n",
    "\n",
    "- 名称/值对：代表数据，名称后跟'：'（冒号），名称/值对以逗号分隔。\n",
    "- 大括号：容纳对象。\n",
    "- 中括号：保留由（，）分隔的值的数组。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'dict'>\n",
      "dict_keys(['squadName', 'homeTown', 'formed', 'secretBase', 'active', 'members'])\n"
     ]
    }
   ],
   "source": [
    "# 需要导入 json库, 接着我们使用open函数来读取JSON文件,最后利用json.load()函数将JSON字符串转化为Python字典形式\n",
    "import json\n",
    "\n",
    "with open('superheroes.json') as f:\n",
    "    superHeroSquad = json.load(f)\n",
    "\n",
    "print(type(superHeroSquad))  # Output: dict\n",
    "print(superHeroSquad.keys())\n",
    "# Output: dict_keys(['squadName', 'homeTown', 'formed', 'secretBase', 'active', 'members'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>squadName</th>\n",
       "      <th>homeTown</th>\n",
       "      <th>formed</th>\n",
       "      <th>secretBase</th>\n",
       "      <th>active</th>\n",
       "      <th>members</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Super Hero Squad</td>\n",
       "      <td>Metro City</td>\n",
       "      <td>2016</td>\n",
       "      <td>Super tower</td>\n",
       "      <td>True</td>\n",
       "      <td>{'name': 'Molecule Man', 'age': 29, 'secretIde...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Super Hero Squad</td>\n",
       "      <td>Metro City</td>\n",
       "      <td>2016</td>\n",
       "      <td>Super tower</td>\n",
       "      <td>True</td>\n",
       "      <td>{'name': 'Madame Uppercut', 'age': 39, 'secret...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Super Hero Squad</td>\n",
       "      <td>Metro City</td>\n",
       "      <td>2016</td>\n",
       "      <td>Super tower</td>\n",
       "      <td>True</td>\n",
       "      <td>{'name': 'Eternal Flame', 'age': 1000000, 'sec...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          squadName    homeTown  formed   secretBase  active  \\\n",
       "0  Super Hero Squad  Metro City    2016  Super tower    True   \n",
       "1  Super Hero Squad  Metro City    2016  Super tower    True   \n",
       "2  Super Hero Squad  Metro City    2016  Super tower    True   \n",
       "\n",
       "                                             members  \n",
       "0  {'name': 'Molecule Man', 'age': 29, 'secretIde...  \n",
       "1  {'name': 'Madame Uppercut', 'age': 39, 'secret...  \n",
       "2  {'name': 'Eternal Flame', 'age': 1000000, 'sec...  "
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_json('https://mdn.github.io/learning-area/javascript/oojs/json/superheroes.json')\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "def test():\n",
    "    with open('superheroes.json') as f:\n",
    "        superHeroSquad = json.load(f)\n",
    "    out = pd.json_normalize(superHeroSquad, record_path=['members'],\n",
    "                    meta=['squadName', 'homeTown', 'formed', 'secretBase', 'active'],\n",
    "                    meta_prefix = 'members_')\n",
    "    return out"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- `record_path`为我们希望拆分的列的名字\n",
    "- `meta`为列名的list，为我们输出的次序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>name</th>\n",
       "      <th>age</th>\n",
       "      <th>secretIdentity</th>\n",
       "      <th>powers</th>\n",
       "      <th>members_squadName</th>\n",
       "      <th>members_homeTown</th>\n",
       "      <th>members_formed</th>\n",
       "      <th>members_secretBase</th>\n",
       "      <th>members_active</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Molecule Man</td>\n",
       "      <td>29</td>\n",
       "      <td>Dan Jukes</td>\n",
       "      <td>[Radiation resistance, Turning tiny, Radiation...</td>\n",
       "      <td>Super Hero Squad</td>\n",
       "      <td>Metro City</td>\n",
       "      <td>2016</td>\n",
       "      <td>Super tower</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Madame Uppercut</td>\n",
       "      <td>39</td>\n",
       "      <td>Jane Wilson</td>\n",
       "      <td>[Million tonne punch, Damage resistance, Super...</td>\n",
       "      <td>Super Hero Squad</td>\n",
       "      <td>Metro City</td>\n",
       "      <td>2016</td>\n",
       "      <td>Super tower</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Eternal Flame</td>\n",
       "      <td>1000000</td>\n",
       "      <td>Unknown</td>\n",
       "      <td>[Immortality, Heat Immunity, Inferno, Teleport...</td>\n",
       "      <td>Super Hero Squad</td>\n",
       "      <td>Metro City</td>\n",
       "      <td>2016</td>\n",
       "      <td>Super tower</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              name      age secretIdentity  \\\n",
       "0     Molecule Man       29      Dan Jukes   \n",
       "1  Madame Uppercut       39    Jane Wilson   \n",
       "2    Eternal Flame  1000000        Unknown   \n",
       "\n",
       "                                              powers members_squadName  \\\n",
       "0  [Radiation resistance, Turning tiny, Radiation...  Super Hero Squad   \n",
       "1  [Million tonne punch, Damage resistance, Super...  Super Hero Squad   \n",
       "2  [Immortality, Heat Immunity, Inferno, Teleport...  Super Hero Squad   \n",
       "\n",
       "  members_homeTown members_formed members_secretBase members_active  \n",
       "0       Metro City           2016        Super tower           True  \n",
       "1       Metro City           2016        Super tower           True  \n",
       "2       Metro City           2016        Super tower           True  "
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "superHeroSquad['members']['2']['secretIdentity'] = 'jing jing'\n",
    "with open('superheroes.json', 'w') as file:\n",
    "    json.dump(superHeroSquad, file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_json('superheroes.json')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"2name\": \"lucy\", \"1sex\": \"boy\"}\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    " \n",
    "dicts={\"2name\":\"lucy\",\"1sex\":\"boy\"}\n",
    " \n",
    "json_dicts=json.dumps(dicts)\n",
    "#将Python的字典数据转换成json字符\n",
    "print(json_dicts)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\n",
      "    \"1sex\": \"boy\",\n",
      "    \"2name\": \"lucy\"\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    " \n",
    "dicts={\"2name\":\"lucy\",\"1sex\":\"boy\"}\n",
    " \n",
    "json_dicts=json.dumps(dicts,indent=4,sort_keys=True)\n",
    "print(json_dicts)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 读取html"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```python\n",
    "pandas.read_html(io, match='.+', flavor=None, header=None, index_col=None, skiprows=None, attrs=None, parse_dates=False, tupleize_cols=None, thousands=', ', encoding=None, decimal='.', converters=None, na_values=None, keep_default_na=True, displayed_only=True)\n",
    "```\n",
    "\n",
    "常用的参数：\n",
    "- io:可以是url、html文本、本地文件等；\n",
    "- flavor：解析器；\n",
    "- header：标题行；\n",
    "- skiprows：跳过的行；\n",
    "- attrs：属性，比如 attrs = {'id': 'table'}；\n",
    "- parse_dates：解析日期\n",
    "\n",
    "注意：返回的结果是**DataFrame**组成的**list**。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>关注</th>\n",
       "      <th>比较</th>\n",
       "      <th>序号</th>\n",
       "      <th>基金代码</th>\n",
       "      <th>基金简称</th>\n",
       "      <th>单位净值</th>\n",
       "      <th>累计净值</th>\n",
       "      <th>单位净值.1</th>\n",
       "      <th>累计净值.1</th>\n",
       "      <th>日增长值</th>\n",
       "      <th>日增长率</th>\n",
       "      <th>申购状态</th>\n",
       "      <th>赎回状态</th>\n",
       "      <th>手续费</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>7872</td>\n",
       "      <td>金信稳健策略灵活配置混合估值图基金吧</td>\n",
       "      <td>1.7711</td>\n",
       "      <td>1.7711</td>\n",
       "      <td>1.7220</td>\n",
       "      <td>1.7220</td>\n",
       "      <td>0.0491</td>\n",
       "      <td>2.85%</td>\n",
       "      <td>开放</td>\n",
       "      <td>开放</td>\n",
       "      <td>0.15%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>50012</td>\n",
       "      <td>博时策略混合估值图基金吧</td>\n",
       "      <td>1.8110</td>\n",
       "      <td>2.0800</td>\n",
       "      <td>1.7610</td>\n",
       "      <td>2.0300</td>\n",
       "      <td>0.0500</td>\n",
       "      <td>2.84%</td>\n",
       "      <td>开放</td>\n",
       "      <td>开放</td>\n",
       "      <td>0.15%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3</td>\n",
       "      <td>2256</td>\n",
       "      <td>金信行业优选混合发起式估值图基金吧</td>\n",
       "      <td>2.1060</td>\n",
       "      <td>2.1060</td>\n",
       "      <td>2.0480</td>\n",
       "      <td>2.0480</td>\n",
       "      <td>0.0580</td>\n",
       "      <td>2.83%</td>\n",
       "      <td>开放</td>\n",
       "      <td>开放</td>\n",
       "      <td>0.15%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>4</td>\n",
       "      <td>11982</td>\n",
       "      <td>博时内需增长混合C估值图基金吧</td>\n",
       "      <td>1.6130</td>\n",
       "      <td>1.6130</td>\n",
       "      <td>1.5700</td>\n",
       "      <td>1.5700</td>\n",
       "      <td>0.0430</td>\n",
       "      <td>2.74%</td>\n",
       "      <td>开放</td>\n",
       "      <td>开放</td>\n",
       "      <td>0.00%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>5</td>\n",
       "      <td>264</td>\n",
       "      <td>博时内需增长混合A估值图基金吧</td>\n",
       "      <td>1.6210</td>\n",
       "      <td>1.4170</td>\n",
       "      <td>1.5780</td>\n",
       "      <td>1.3790</td>\n",
       "      <td>0.0430</td>\n",
       "      <td>2.72%</td>\n",
       "      <td>开放</td>\n",
       "      <td>开放</td>\n",
       "      <td>0.15%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>195</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>196</td>\n",
       "      <td>7578</td>\n",
       "      <td>宝盈新锐混合C估值图基金吧</td>\n",
       "      <td>3.5990</td>\n",
       "      <td>3.5990</td>\n",
       "      <td>3.5650</td>\n",
       "      <td>3.5650</td>\n",
       "      <td>0.0340</td>\n",
       "      <td>0.95%</td>\n",
       "      <td>开放</td>\n",
       "      <td>开放</td>\n",
       "      <td>0.00%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>196</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>197</td>\n",
       "      <td>1476</td>\n",
       "      <td>中银智能制造股票A估值图基金吧</td>\n",
       "      <td>2.2300</td>\n",
       "      <td>2.2300</td>\n",
       "      <td>2.2090</td>\n",
       "      <td>2.2090</td>\n",
       "      <td>0.0210</td>\n",
       "      <td>0.95%</td>\n",
       "      <td>开放</td>\n",
       "      <td>开放</td>\n",
       "      <td>0.15%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>197</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>198</td>\n",
       "      <td>12181</td>\n",
       "      <td>中银智能制造股票C估值图基金吧</td>\n",
       "      <td>2.2220</td>\n",
       "      <td>2.2220</td>\n",
       "      <td>2.2010</td>\n",
       "      <td>2.2010</td>\n",
       "      <td>0.0210</td>\n",
       "      <td>0.95%</td>\n",
       "      <td>开放</td>\n",
       "      <td>开放</td>\n",
       "      <td>0.00%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>198</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>199</td>\n",
       "      <td>15575</td>\n",
       "      <td>宝盈新能源产业混合发起式C估值图基金吧</td>\n",
       "      <td>1.1302</td>\n",
       "      <td>1.1302</td>\n",
       "      <td>1.1196</td>\n",
       "      <td>1.1196</td>\n",
       "      <td>0.0106</td>\n",
       "      <td>0.95%</td>\n",
       "      <td>开放</td>\n",
       "      <td>开放</td>\n",
       "      <td>0.00%</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>199</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>200</td>\n",
       "      <td>6868</td>\n",
       "      <td>华夏科技成长股票估值图基金吧</td>\n",
       "      <td>1.7835</td>\n",
       "      <td>1.7835</td>\n",
       "      <td>1.7669</td>\n",
       "      <td>1.7669</td>\n",
       "      <td>0.0166</td>\n",
       "      <td>0.94%</td>\n",
       "      <td>限大额</td>\n",
       "      <td>开放</td>\n",
       "      <td>0.15%</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>200 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     关注  比较   序号   基金代码                 基金简称    单位净值    累计净值  单位净值.1  累计净值.1  \\\n",
       "0   NaN NaN    1   7872   金信稳健策略灵活配置混合估值图基金吧  1.7711  1.7711  1.7220  1.7220   \n",
       "1   NaN NaN    2  50012         博时策略混合估值图基金吧  1.8110  2.0800  1.7610  2.0300   \n",
       "2   NaN NaN    3   2256    金信行业优选混合发起式估值图基金吧  2.1060  2.1060  2.0480  2.0480   \n",
       "3   NaN NaN    4  11982      博时内需增长混合C估值图基金吧  1.6130  1.6130  1.5700  1.5700   \n",
       "4   NaN NaN    5    264      博时内需增长混合A估值图基金吧  1.6210  1.4170  1.5780  1.3790   \n",
       "..   ..  ..  ...    ...                  ...     ...     ...     ...     ...   \n",
       "195 NaN NaN  196   7578        宝盈新锐混合C估值图基金吧  3.5990  3.5990  3.5650  3.5650   \n",
       "196 NaN NaN  197   1476      中银智能制造股票A估值图基金吧  2.2300  2.2300  2.2090  2.2090   \n",
       "197 NaN NaN  198  12181      中银智能制造股票C估值图基金吧  2.2220  2.2220  2.2010  2.2010   \n",
       "198 NaN NaN  199  15575  宝盈新能源产业混合发起式C估值图基金吧  1.1302  1.1302  1.1196  1.1196   \n",
       "199 NaN NaN  200   6868       华夏科技成长股票估值图基金吧  1.7835  1.7835  1.7669  1.7669   \n",
       "\n",
       "       日增长值   日增长率 申购状态 赎回状态    手续费  \n",
       "0    0.0491  2.85%   开放   开放  0.15%  \n",
       "1    0.0500  2.84%   开放   开放  0.15%  \n",
       "2    0.0580  2.83%   开放   开放  0.15%  \n",
       "3    0.0430  2.74%   开放   开放  0.00%  \n",
       "4    0.0430  2.72%   开放   开放  0.15%  \n",
       "..      ...    ...  ...  ...    ...  \n",
       "195  0.0340  0.95%   开放   开放  0.00%  \n",
       "196  0.0210  0.95%   开放   开放  0.15%  \n",
       "197  0.0210  0.95%   开放   开放  0.00%  \n",
       "198  0.0106  0.95%   开放   开放  0.00%  \n",
       "199  0.0166  0.94%  限大额   开放  0.15%  \n",
       "\n",
       "[200 rows x 14 columns]"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = \"https://fund.eastmoney.com/fund.html#os_0;isall_0;ft_;pt_1\"\n",
    "table = pd.read_html(url, attrs = {'id': 'oTable'}, header=1)\n",
    "type(table) \n",
    "# list\n",
    "len(table)\n",
    "# 1\n",
    "table[0]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
